<template >
    <div class="box" @click.stop.prevent="$emit('on-click', task)">
        <input id="checkbox" :checked="task?.checked" class="checkbox" type="checkbox" />
        <label for="checkbox"></label>
    </div>
</template>
<script setup lang="ts">
import { defineProps } from 'vue';

type Task = {
    taskID: string,
    taskName: string,
    checked: boolean,
    time: number
}
type Props = {
    task?: Task
}
defineProps<Props>()
defineEmits(['on-click'])

</script>
<style lang="less" scoped>
.box {
    position: relative;
    width: 1.5rem;
    height: 1.5rem;

    label {
        display: block;
        width: 1.5rem;
        height: 1.5rem;
        line-height: 1.5rem;
        cursor: pointer;
        position: absolute;
        border: 1px solid #adcdfc;
        /*改变复选框的边框颜色也可以不要边框*/
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        transition: all 0.3s ease;

        &:before {
            transition: all 0.3s ease;
        }
    }

    /*	隐藏CheckBox属性原来的样式*/
    input[type=checkbox] {
        /* visibility 属性规定元素是否可见*/
        visibility: hidden;
    }

    /* checked 预先选定复选框或单选按钮。*/
    .checkbox:checked+label:before {
        /*before为伪元素可以在元素之后添加内容*/
        display: flex;
        /*	css3中的content字符编码*/
        content: "\2714";
        /*	复选框里面的&radic;居中*/
        align-items: center;
        justify-content: center;
        /*	复选框里面的&radic;大小*/
        font-size: 20px;
        /*	字体的颜色*/
        color: #fff;
        /*  复选框勾选后的背景颜色*/
        background: #adcdfc;
        transition: all 0.3s ease;
    }

    .checkbox:checked+label {
        border: 1px solid transparent;
    }



}
</style>